package summer.hot100.v1;

import java.util.LinkedList;

public class Solution155 {

}

class MinStack {
    LinkedList<Integer> s1;
    LinkedList<Integer> s2;

    public MinStack() {
        s1 = new LinkedList<>();
        s2 = new LinkedList<>();
    }

    public void push(int val) {
        if (s2.isEmpty() || getMin() > val) s2.add(val);
        else s2.add(getMin());
        s1.add(val);
    }

    public void pop() {
        s2.removeLast();
        s1.removeLast();
    }

    public int top() {
        return s1.getLast();
    }

    public int getMin() {
        return s2.getLast();
    }
}